package com.team.mp.api.controller;

import com.team.mp.api.service.intf.LabelService;
import com.team.mp.constants.SystemConfig;
import com.team.mp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/label/")
@Api(tags = "标签相关接口")
public class LabelController {
    @Resource
    private LabelService service;

    /**
     * 新增内容*/
    @ApiOperation(value = "新增标签")
    @PostMapping("save")
    public R save(String name, HttpServletRequest request){
        return service.save(name,request.getHeader(SystemConfig.HEADER_AUTH));
    }

    /**
     * 查询 所有数据*/
    @ApiOperation(value = "查询全部标签")
    @GetMapping("all")
    public R all(){
        return service.queryAll();
    }
    /**
     * 修改标签名称
     */
    @ApiOperation(value = "修改标签名称")
    @PostMapping("update")
    public R update(String name, Integer id){
        return service.update(name,id);
    }
    /**
     * 修改状态
     */
    @ApiOperation(value = "修改标签名称")
    @PostMapping("updatestatus")
    public R updateStatus(Integer id){
        return service.updateStatus(id);
    }
    /**
     * 删除标签
     */
    @ApiOperation(value = "删除标签")
    @DeleteMapping("del")
    public R del(long id){
        return service.del(id);
    }
    /**
     * 分页查询
     */
    /**
     * 查询 所有数据*/
    @ApiOperation(value = "分页查询")
    @GetMapping("page")
    public R page(String name,int page,int size){
        return service.queryPage(name,page,size);
    }


}
